# -*- coding: utf8 -*-

from project.db import DataBase


class TableManager(object):

    _table = None

    tables = (
        "option", "directory", "file", "hash", "image",
        "image_vector10", "image_vector_big", "image_vector_numpy", "image_vector_bitstr",
         "image_vector_gray",
        "image2image", "file2file",
    )

    def __init__(self):
        self._table = {}
        pass


    def getTable(self, name):
        if name not in self._table:
            if name == "option":
                from project.mysql.table_option import TableOption
                self._table[ name ] = TableOption()
            elif name == "directory":
                from project.mysql.table_directory import TableDirectory
                self._table[ name ] = TableDirectory()
            elif name == "file":
                from project.mysql.table_file import TableFile
                self._table[ name ] = TableFile()
            elif name == "hash":
                from project.mysql.table_hash import TableHash
                self._table[ name ] = TableHash()
            elif name == "image":
                from project.mysql.table_image import TableImage
                self._table[ name ] = TableImage()
            elif name == "image_vector10":
                from project.mysql.table_image_vector10 import TableImageVector10
                self._table[ name ] = TableImageVector10()
            elif name == "image_vector_big":
                from project.mysql.table_image_vector_big import TableImageVectorBig
                self._table[ name ] = TableImageVectorBig()
            elif name == "image_vector_numpy":
                from project.mysql.table_image_vector_numpy import TableImageVectorNumpy
                self._table[ name ] = TableImageVectorNumpy()
            elif name == "image_vector_bitstr":
                from project.mysql.table_image_vector_bitstr import TableImageVectorBitstr
                self._table[ name ] = TableImageVectorBitstr()
            elif name == "image_vector_gray":
                from project.mysql.table_image_vector_gray import TableImageVectorGray
                self._table[ name ] = TableImageVectorGray()
            elif name == "image2image":
                from project.mysql.table_image2image import TableImage2Image
                self._table[ name ] = TableImage2Image()
            elif name == "file2file":
                from project.mysql.table_file2file import TableFile2file
                self._table[ name ] = TableFile2file()
            connection = DataBase()
            self._table[ name ].setDb(connection)
        return self._table[ name ]

    pass
